home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_11_05 / test_obj / t001.cpp < prev    next >
C/C++ Source or Header  |  1993-01-20  |  3KB  |  110 lines

  1.  
  2. #include "testgen.h"
  3. #include "invoice.h"
  4.  
  5. void r1_bottom(int vals[], Item& someItem,int numItems,Invoice& theInvoice,Client& someClient)
  6. {
  7.    cout << "TESTING CLIENTS & NO. OF ITEMS\n";
  8.    cout << "client: " << someClient << "\n";
  9.    cout << "items are:\n";
  10.    for (int i = 0; i < numItems; i++) {
  11.      theInvoice.addItem(&someItem);
  12.      cout << " " << someItem << "\n";
  13.    }
  14.    cout << "total discount: "
  15.         << theInvoice.totalDiscount() << "\n";
  16. }
  17.  
  18. void r1_someItem(int vals[], int numItems,Invoice& theInvoice,Client& someClient){
  19. Item someItem[] = {
  20. Item(100, 10, 1.00),
  21. Item(1100, 5, 5.00)};
  22.   r1_bottom(vals,someItem[vals[3]],numItems,theInvoice,someClient);
  23.  
  24. }
  25.  
  26. void r1_numItems(int vals[], Invoice& theInvoice,Client& someClient){
  27. int numItems[] = {
  28. 1,
  29. 0,
  30. 4};
  31.   r1_someItem(vals,numItems[vals[2]],theInvoice,someClient);
  32.  
  33. }
  34.  
  35. void r1_theInvoice(int vals[], Client& someClient){
  36. Invoice theInvoice[] = {
  37. Invoice(&someClient)};
  38.   r1_numItems(vals,theInvoice[vals[1]],someClient);
  39.  
  40. }
  41.  
  42. void r1_someClient(int vals[]){
  43.  Client someClient[] = {
  44. Client(RETAIL),
  45. Client(WHOLESALE),
  46. Client(FOREIGN)};
  47.   r1_theInvoice(vals,someClient[vals[0]]);
  48.  
  49. }
  50.  
  51. void r2_bottom(int vals[], Item& otherItem,Item& someItem,Invoice& theInvoice,Client& someClient)
  52. {
  53.    cout << "TESTING MIXING ITEMS\n";
  54.    cout << "client: " << someClient << "\n";
  55.    cout << "items are:\n";
  56.    theInvoice.addItem(&someItem);
  57.    cout << " " << someItem << "\n";
  58.    theInvoice.addItem(&otherItem);
  59.    cout << " " << otherItem << "\n";
  60.    cout << "total discount: "
  61.         << theInvoice.totalDiscount() << "\n";
  62. }
  63.  
  64. void r2_otherItem(int vals[], Item& someItem,Invoice& theInvoice,Client& someClient){
  65. Item otherItem[] = {
  66. Item(100, 10, 1.00),
  67. Item(1100, 5, 5.00)};
  68.   r2_bottom(vals,otherItem[vals[3]],someItem,theInvoice,someClient);
  69.  
  70. }
  71.  
  72. void r2_someItem(int vals[], Invoice& theInvoice,Client& someClient){
  73. Item someItem[] = {
  74. Item(100, 10, 1.00),
  75. Item(1100, 5, 5.00)};
  76.   r2_otherItem(vals,someItem[vals[2]],theInvoice,someClient);
  77.  
  78. }
  79.  
  80. void r2_theInvoice(int vals[], Client& someClient){
  81. Invoice theInvoice[] = {
  82. Invoice(&someClient)};
  83.   r2_someItem(vals,theInvoice[vals[1]],someClient);
  84.  
  85. }
  86.  
  87. void r2_someClient(int vals[]){
  88.  Client someClient[] = {
  89. Client(RETAIL),
  90. Client(WHOLESALE),
  91. Client(FOREIGN)};
  92.   r2_theInvoice(vals,someClient[vals[0]]);
  93.  
  94. }
  95.  
  96. void main() {
  97. int nvals_r1[4] = { 3,1,3,2 };
  98. Test_gen_combining g_r1(4, nvals_r1);
  99. int vals_r1[4] = { -1 };
  100. int nvals_r2[4] = { 3,1,2,2 };
  101. Test_gen_combining g_r2(4, nvals_r2);
  102. int vals_r2[4] = { -1 };
  103. while (g_r1.next_vector(vals_r1) == YES) {
  104.    r1_someClient(vals_r1);
  105. };
  106. while (g_r2.next_vector(vals_r2) == YES) {
  107.    r2_someClient(vals_r2);
  108. };
  109. }
  110.